import java.util.*;

public class Test {

    public int singleNumber(int[] array) {
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < array.length; i++) {
            if (set.contains(array[i])) {
                set.remove(array[i]);
            }else {
                set.add(array[i]);
            }
        }
        for (int i = 0; i < array.length; i++) {
            if (set.contains(array[i])) {
                return array[i];
            }
        }
        return -1;
    }

    public static void main4(String[] args) {
        int[] array = {8,12,5,6,8,47,56,12,8,23,15,87,19,67,95,10,15};
        Map<Integer,Integer> map = new HashMap<>();
        for (int x: array) {
            if (map.get(x) == null) {
                map.put(x,1);
            }else {
                int val = map.get(x);
                map.put(x,val+1);
            }
        }
        for (Map.Entry<Integer,Integer> entry :map.entrySet()) {
            if (entry.getValue() > 1) {
                System.out.println("key:"+entry.getKey()+" val:"+entry.getValue());
            }
        }

    }

    public static void main3(String[] args) {
        int[] array = {8,12,5,6,8,47,56,12,23,15,87,19,67,95,10,15};
        Set<Integer> set = new TreeSet<>();
        for (Integer i: array) {
            set.add(i);
        }
        System.out.println(set);
    }

    public static void main2(String[] args) {
        HashBuck hashBuck = new HashBuck();
        hashBuck.put(1,11);
        hashBuck.put(2,22);
        hashBuck.put(5,55);
        hashBuck.put(8,88);
        hashBuck.put(7,77);
        hashBuck.put(13,133);
        hashBuck.put(4,44);
        hashBuck.put(9,99);
        hashBuck.put(14,144);
        hashBuck.put(19,199);
        System.out.println(hashBuck.get(51));
    }

    public static void main1(String[] args) {
        TreeMap<String,Integer> treeMap = new TreeMap<>();
        treeMap.put("hello",4);
        treeMap.put("abc",3);
        treeMap.put("shy",5);
        System.out.println(treeMap);
    }

}
